﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ClassLibrary.DAO;

public partial class ucControl_ucDefault : System.Web.UI.UserControl
{
    TblMenuParrentDAO menuPaDAO = new TblMenuParrentDAO(Global.CONNECTION_STRING);
    DVKhachhangDAO dvkhDAO = new DVKhachhangDAO(Global.CONNECTION_STRING);
    TblPopupDAO popupDAO = new TblPopupDAO(Global.CONNECTION_STRING);
    TblTinTucSuKienDAO tintucDAO = new TblTinTucSuKienDAO(Global.CONNECTION_STRING);
    TblKhuyenMaiDAO kmDAO = new TblKhuyenMaiDAO(Global.CONNECTION_STRING);

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadDongXe();
            LoadTopKH();
            LoadPopup();
            LoadTinTucSK();
            LoadKM();
        }
    }

    private void LoadKM()
    {
        formKM.DataSource = kmDAO.GetTopKM();
        formKM.DataBind();
    }

    private void LoadTinTucSK()
    {
        rpTinTuc.DataSource = tintucDAO.GetTinTucSK();
        rpTinTuc.DataBind();

    }
    private void LoadDongXe()
    {
        rpDongxe.DataSource = menuPaDAO.GetAll();
        rpDongxe.DataBind();
    }

    private void LoadTopKH()
    {
        rpKhachhang.DataSource = dvkhDAO.GetDVKH_Top();
        rpKhachhang.DataBind();
    }

    private void LoadPopup()
    {
        formPopup.DataSource = popupDAO.GetPopup();
        formPopup.DataBind();
    }
}
